<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <script src="../lib/jQuery/jquery.min.js"></script>
    <script>
        //1.symbol的值是唯一的,永远不相等
        var foo1 = Symbol();
        var foo2 = Symbol();

        console.log(foo1 == foo2);

        var foo3 = Symbol('这是独一无二的描述');

        console.log(foo3);
        console.log(foo3.description); // 获取symbol的描述值

        var s = Symbol('这是描述年龄的');
        var color = Symbol('我是color的唯一');

        var obj = {
            name: '李四',
            [s]: '30'
        }

        console.log(obj);
        console.log(obj[s]); // 取值

        var obj2 = {
            name: '小狗',
            age: 50
        }
        obj2[color] = 'red';

        console.log(obj2);
        console.log(obj2[color]);

        // forin遍历symbol 无法取到
        for (const i in obj2) {
            // console.log(i);
            // console.log(obj2[i]);
            // console.log(i == obj2[i]);
        }
        
        console.log(color in obj);
    </script>
</body>

</html>